package com.intelligentclass.repositories;

import com.intelligentclass.entity.Courseware;
import com.intelligentclass.entity.Exercise;
import com.intelligentclass.entity.Historypaper;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface HistorypaperRespository extends JpaRepository<Historypaper, Integer> {

    @Query("select h from Historypaper h where h.cid = :cid")
    public List<Historypaper> findAllByCid(@Param("cid")int cid);

    @Query("select c from Historypaper c where c.cid = :cid and c.name = :name")
    public Historypaper findByCidAndName(@Param("cid") int cid, @Param("name") String name);

    @Query("select e from Historypaper e where e.cid = :cid and e.name = :name and e.parent = :parent")
    public Historypaper find(@Param("cid") int cid, @Param("name") String name, @Param("parent") int parent);
}
